(function(){this.canvg=function(e,i,n){if(e==null&&i==null&&n==null){var a=document.getElementsByTagName("svg");for(var s=0;s<a.length;s++){var r=a[s];var l=document.createElement("canvas");l.width=r.clientWidth;l.height=r.clientHeight;r.parentNode.insertBefore(l,r);r.parentNode.removeChild(r);var o=document.createElement("div");o.appendChild(r);canvg(l,o.innerHTML)}return}n=n||{};if(typeof e=="string"){e=document.getElementById(e)}if(e.svg!=null)e.svg.stop();var h=t();if(!(e.childNodes.length==1&&e.childNodes[0].nodeName=="OBJECT"))e.svg=h;h.opts=n;var u=e.getContext("2d");if(typeof i.documentElement!="undefined"){h.loadXmlDoc(u,i)}else if(i.substr(0,1)=="<"){h.loadXml(u,i)}else{h.load(u,i)}};function t(){var t={};t.FRAMERATE=30;t.MAX_VIRTUAL_PIXELS=3e4;t.init=function(e){var i=0;t.UniqueId=function(){i++;return"canvg"+i};t.Definitions={};t.Styles={};t.Animations=[];t.Images=[];t.ctx=e;t.ViewPort=new function(){this.viewPorts=[];this.Clear=function(){this.viewPorts=[]};this.SetCurrent=function(t,e){this.viewPorts.push({width:t,height:e})};this.RemoveCurrent=function(){this.viewPorts.pop()};this.Current=function(){return this.viewPorts[this.viewPorts.length-1]};this.width=function(){return this.Current().width};this.height=function(){return this.Current().height};this.ComputeSize=function(t){if(t!=null&&typeof t=="number")return t;if(t=="x")return this.width();if(t=="y")return this.height();return Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2)}}};t.init();t.ImagesLoaded=function(){for(var e=0;e<t.Images.length;e++){if(!t.Images[e].loaded)return false}return true};t.trim=function(t){return t.replace(/^\s+|\s+$/g,"")};t.compressSpaces=function(t){return t.replace(/[\s\r\t\n]+/gm," ")};t.ajax=function(t){var e;if(window.XMLHttpRequest){e=new XMLHttpRequest}else{e=new ActiveXObject("Microsoft.XMLHTTP")}if(e){e.open("GET",t,false);e.send(null);return e.responseText}return null};t.parseXml=function(t){if(window.DOMParser){var e=new DOMParser;return e.parseFromString(t,"text/xml")}else{t=t.replace(/<!DOCTYPE svg[^>]*>/,"");var i=new ActiveXObject("Microsoft.XMLDOM");i.async="false";i.loadXML(t);return i}};t.Property=function(t,e){this.name=t;this.value=e};t.Property.prototype.getValue=function(){return this.value};t.Property.prototype.hasValue=function(){return this.value!=null&&this.value!==""};t.Property.prototype.numValue=function(){if(!this.hasValue())return 0;var t=parseFloat(this.value);if((this.value+"").match(/%$/)){t=t/100}return t};t.Property.prototype.valueOrDefault=function(t){if(this.hasValue())return this.value;return t};t.Property.prototype.numValueOrDefault=function(t){if(this.hasValue())return this.numValue();return t};t.Property.prototype.addOpacity=function(e){var i=this.value;if(e!=null&&e!=""&&typeof this.value=="string"){var n=new RGBColor(this.value);if(n.ok){i="rgba("+n.r+", "+n.g+", "+n.b+", "+e+")"}}return new t.Property(this.name,i)};t.Property.prototype.getDefinition=function(){var e=this.value.match(/#([^\)'"]+)/);if(e){e=e[1]}if(!e){e=this.value}return t.Definitions[e]};t.Property.prototype.isUrlDefinition=function(){return this.value.indexOf("url(")==0};t.Property.prototype.getFillStyleDefinition=function(e,i){var n=this.getDefinition();if(n!=null&&n.createGradient){return n.createGradient(t.ctx,e,i)}if(n!=null&&n.createPattern){if(n.getHrefAttribute().hasValue()){var a=n.attribute("patternTransform");n=n.getHrefAttribute().getDefinition();if(a.hasValue()){n.attribute("patternTransform",true).value=a.value}}return n.createPattern(t.ctx,e)}return null};t.Property.prototype.getDPI=function(t){return 96};t.Property.prototype.getEM=function(e){var i=12;var n=new t.Property("fontSize",t.Font.Parse(t.ctx.font).fontSize);if(n.hasValue())i=n.toPixels(e);return i};t.Property.prototype.getUnits=function(){var t=this.value+"";return t.replace(/[0-9\.\-]/g,"")};t.Property.prototype.toPixels=function(e,i){if(!this.hasValue())return 0;var n=this.value+"";if(n.match(/em$/))return this.numValue()*this.getEM(e);if(n.match(/ex$/))return this.numValue()*this.getEM(e)/2;if(n.match(/px$/))return this.numValue();if(n.match(/pt$/))return this.numValue()*this.getDPI(e)*(1/72);if(n.match(/pc$/))return this.numValue()*15;if(n.match(/cm$/))return this.numValue()*this.getDPI(e)/2.54;if(n.match(/mm$/))return this.numValue()*this.getDPI(e)/25.4;if(n.match(/in$/))return this.numValue()*this.getDPI(e);if(n.match(/%$/))return this.numValue()*t.ViewPort.ComputeSize(e);var a=this.numValue();if(i&&a<1)return a*t.ViewPort.ComputeSize(e);return a};t.Property.prototype.toMilliseconds=function(){if(!this.hasValue())return 0;var t=this.value+"";if(t.match(/s$/))return this.numValue()*1e3;if(t.match(/ms$/))return this.numValue();return this.numValue()};t.Property.prototype.toRadians=function(){if(!this.hasValue())return 0;var t=this.value+"";if(t.match(/deg$/))return this.numValue()*(Math.PI/180);if(t.match(/grad$/))return this.numValue()*(Math.PI/200);if(t.match(/rad$/))return this.numValue();return this.numValue()*(Math.PI/180)};t.Font=new function(){this.Styles="normal|italic|oblique|inherit";this.Variants="normal|small-caps|inherit";this.Weights="normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit";this.CreateFont=function(e,i,n,a,s,r){var l=r!=null?this.Parse(r):this.CreateFont("","","","","",t.ctx.font);return{fontFamily:s||l.fontFamily,fontSize:a||l.fontSize,fontStyle:e||l.fontStyle,fontWeight:n||l.fontWeight,fontVariant:i||l.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var e=this;this.Parse=function(i){var n={};var a=t.trim(t.compressSpaces(i||"")).split(" ");var s={fontSize:false,fontStyle:false,fontWeight:false,fontVariant:false};var r="";for(var l=0;l<a.length;l++){if(!s.fontStyle&&e.Styles.indexOf(a[l])!=-1){if(a[l]!="inherit")n.fontStyle=a[l];s.fontStyle=true}else if(!s.fontVariant&&e.Variants.indexOf(a[l])!=-1){if(a[l]!="inherit")n.fontVariant=a[l];s.fontStyle=s.fontVariant=true}else if(!s.fontWeight&&e.Weights.indexOf(a[l])!=-1){if(a[l]!="inherit")n.fontWeight=a[l];s.fontStyle=s.fontVariant=s.fontWeight=true}else if(!s.fontSize){if(a[l]!="inherit")n.fontSize=a[l].split("/")[0];s.fontStyle=s.fontVariant=s.fontWeight=s.fontSize=true}else{if(a[l]!="inherit")r+=a[l]}}if(r!="")n.fontFamily=r;return n}};t.ToNumberArray=function(e){var i=t.trim(t.compressSpaces((e||"").replace(/,/g," "))).split(" ");for(var n=0;n<i.length;n++){i[n]=parseFloat(i[n])}return i};t.Point=function(t,e){this.x=t;this.y=e};t.Point.prototype.angleTo=function(t){return Math.atan2(t.y-this.y,t.x-this.x)};t.Point.prototype.applyTransform=function(t){var e=this.x*t[0]+this.y*t[2]+t[4];var i=this.x*t[1]+this.y*t[3]+t[5];this.x=e;this.y=i};t.CreatePoint=function(e){var i=t.ToNumberArray(e);return new t.Point(i[0],i[1])};t.CreatePath=function(e){var i=t.ToNumberArray(e);var n=[];for(var a=0;a<i.length;a+=2){n.push(new t.Point(i[a],i[a+1]))}return n};t.BoundingBox=function(t,e,n,a){this.x1=Number.NaN;this.y1=Number.NaN;this.x2=Number.NaN;this.y2=Number.NaN;this.x=function(){return this.x1};this.y=function(){return this.y1};this.width=function(){return this.x2-this.x1};this.height=function(){return this.y2-this.y1};this.addPoint=function(t,e){if(t!=null){if(isNaN(this.x1)||isNaN(this.x2)){this.x1=t;this.x2=t}if(t<this.x1)this.x1=t;if(t>this.x2)this.x2=t}if(e!=null){if(isNaN(this.y1)||isNaN(this.y2)){this.y1=e;this.y2=e}if(e<this.y1)this.y1=e;if(e>this.y2)this.y2=e}};this.addX=function(t){this.addPoint(t,null)};this.addY=function(t){this.addPoint(null,t)};this.addBoundingBox=function(t){this.addPoint(t.x1,t.y1);this.addPoint(t.x2,t.y2)};this.addQuadraticCurve=function(t,e,i,n,a,s){var r=t+2/3*(i-t);var l=e+2/3*(n-e);var o=r+1/3*(a-t);var h=l+1/3*(s-e);this.addBezierCurve(t,e,r,o,l,h,a,s)};this.addBezierCurve=function(t,e,n,a,s,r,l,o){var h=[t,e],u=[n,a],f=[s,r],c=[l,o];this.addPoint(h[0],h[1]);this.addPoint(c[0],c[1]);for(i=0;i<=1;i++){var m=function(t){return Math.pow(1-t,3)*h[i]+3*Math.pow(1-t,2)*t*u[i]+3*(1-t)*Math.pow(t,2)*f[i]+Math.pow(t,3)*c[i]};var v=6*h[i]-12*u[i]+6*f[i];var d=-3*h[i]+9*u[i]-9*f[i]+3*c[i];var p=3*u[i]-3*h[i];if(d==0){if(v==0)continue;var y=-p/v;if(0<y&&y<1){if(i==0)this.addX(m(y));if(i==1)this.addY(m(y))}continue}var g=Math.pow(v,2)-4*p*d;if(g<0)continue;var x=(-v+Math.sqrt(g))/(2*d);if(0<x&&x<1){if(i==0)this.addX(m(x));if(i==1)this.addY(m(x))}var b=(-v-Math.sqrt(g))/(2*d);if(0<b&&b<1){if(i==0)this.addX(m(b));if(i==1)this.addY(m(b))}}};this.isPointInBox=function(t,e){return this.x1<=t&&t<=this.x2&&this.y1<=e&&e<=this.y2};this.addPoint(t,e);this.addPoint(n,a)};t.Transform=function(e){var i=this;this.Type={};this.Type.translate=function(e){this.p=t.CreatePoint(e);this.apply=function(t){t.translate(this.p.x||0,this.p.y||0)};this.unapply=function(t){t.translate(-1*this.p.x||0,-1*this.p.y||0)};this.applyToPoint=function(t){t.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0])}};this.Type.rotate=function(e){var i=t.ToNumberArray(e);this.angle=new t.Property("angle",i[0]);this.cx=i[1]||0;this.cy=i[2]||0;this.apply=function(t){t.translate(this.cx,this.cy);t.rotate(this.angle.toRadians());t.translate(-this.cx,-this.cy)};this.unapply=function(t){t.translate(this.cx,this.cy);t.rotate(-1*this.angle.toRadians());t.translate(-this.cx,-this.cy)};this.applyToPoint=function(t){var e=this.angle.toRadians();t.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0]);t.applyTransform([Math.cos(e),Math.sin(e),-Math.sin(e),Math.cos(e),0,0]);t.applyTransform([1,0,0,1,-this.p.x||0,-this.p.y||0])}};this.Type.scale=function(e){this.p=t.CreatePoint(e);this.apply=function(t){t.scale(this.p.x||1,this.p.y||this.p.x||1)};this.unapply=function(t){t.scale(1/this.p.x||1,1/this.p.y||this.p.x||1)};this.applyToPoint=function(t){t.applyTransform([this.p.x||0,0,0,this.p.y||0,0,0])}};this.Type.matrix=function(e){this.m=t.ToNumberArray(e);this.apply=function(t){t.transform(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5])};this.applyToPoint=function(t){t.applyTransform(this.m)}};this.Type.SkewBase=function(e){this.base=i.Type.matrix;this.base(e);this.angle=new t.Property("angle",e)};this.Type.SkewBase.prototype=new this.Type.matrix;this.Type.skewX=function(t){this.base=i.Type.SkewBase;this.base(t);this.m=[1,0,Math.tan(this.angle.toRadians()),1,0,0]};this.Type.skewX.prototype=new this.Type.SkewBase;this.Type.skewY=function(t){this.base=i.Type.SkewBase;this.base(t);this.m=[1,Math.tan(this.angle.toRadians()),0,1,0,0]};this.Type.skewY.prototype=new this.Type.SkewBase;this.transforms=[];this.apply=function(t){for(var e=0;e<this.transforms.length;e++){this.transforms[e].apply(t)}};this.unapply=function(t){for(var e=this.transforms.length-1;e>=0;e--){this.transforms[e].unapply(t)}};this.applyToPoint=function(t){for(var e=0;e<this.transforms.length;e++){this.transforms[e].applyToPoint(t)}};var n=t.trim(t.compressSpaces(e)).replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/);for(var a=0;a<n.length;a++){var s=t.trim(n[a].split("(")[0]);var r=n[a].split("(")[1].replace(")","");var l=new this.Type[s](r);l.type=s;this.transforms.push(l)}};t.AspectRatio=function(e,i,n,a,s,r,l,o,h,u){i=t.compressSpaces(i);i=i.replace(/^defer\s/,"");var f=i.split(" ")[0]||"xMidYMid";var c=i.split(" ")[1]||"meet";var m=n/a;var v=s/r;var d=Math.min(m,v);var p=Math.max(m,v);if(c=="meet"){a*=d;r*=d}if(c=="slice"){a*=p;r*=p}h=new t.Property("refX",h);u=new t.Property("refY",u);if(h.hasValue()&&u.hasValue()){e.translate(-d*h.toPixels("x"),-d*u.toPixels("y"))}else{if(f.match(/^xMid/)&&(c=="meet"&&d==v||c=="slice"&&p==v))e.translate(n/2-a/2,0);if(f.match(/YMid$/)&&(c=="meet"&&d==m||c=="slice"&&p==m))e.translate(0,s/2-r/2);if(f.match(/^xMax/)&&(c=="meet"&&d==v||c=="slice"&&p==v))e.translate(n-a,0);if(f.match(/YMax$/)&&(c=="meet"&&d==m||c=="slice"&&p==m))e.translate(0,s-r)}if(f=="none")e.scale(m,v);else if(c=="meet")e.scale(d,d);else if(c=="slice")e.scale(p,p);e.translate(l==null?0:-l,o==null?0:-o)};t.Element={};t.EmptyProperty=new t.Property("EMPTY","");t.Element.ElementBase=function(e){this.attributes={};this.styles={};this.children=[];this.attribute=function(e,i){var n=this.attributes[e];if(n!=null)return n;if(i==true){n=new t.Property(e,"");this.attributes[e]=n}return n||t.EmptyProperty};this.getHrefAttribute=function(){for(var e in this.attributes){if(e.match(/:href$/)){return this.attributes[e]}}return t.EmptyProperty};this.style=function(e,i){var n=this.styles[e];if(n!=null)return n;var a=this.attribute(e);if(a!=null&&a.hasValue()){this.styles[e]=a;return a}var s=this.parent;if(s!=null){var r=s.style(e);if(r!=null&&r.hasValue()){return r}}if(i==true){n=new t.Property(e,"");this.styles[e]=n}return n||t.EmptyProperty};this.render=function(t){if(this.style("display").value=="none")return;if(this.attribute("visibility").value=="hidden")return;t.save();if(this.attribute("mask").hasValue()){var e=this.attribute("mask").getDefinition();if(e!=null)e.apply(t,this)}else if(this.style("filter").hasValue()){var i=this.style("filter").getDefinition();if(i!=null)i.apply(t,this)}else{this.setContext(t);this.renderChildren(t);this.clearContext(t)}t.restore()};this.setContext=function(t){};this.clearContext=function(t){};this.renderChildren=function(t){for(var e=0;e<this.children.length;e++){this.children[e].render(t)}};this.addChild=function(e,i){var n=e;if(i)n=t.CreateElement(e);n.parent=this;this.children.push(n)};if(e!=null&&e.nodeType==1){for(var i=0;i<e.childNodes.length;i++){var n=e.childNodes[i];if(n.nodeType==1)this.addChild(n,true);if(this.captureTextNodes&&n.nodeType==3){var a=n.nodeValue||n.text||"";if(t.trim(t.compressSpaces(a))!=""){this.addChild(new t.Element.tspan(n),false)}}}for(var i=0;i<e.attributes.length;i++){var s=e.attributes[i];this.attributes[s.nodeName]=new t.Property(s.nodeName,s.nodeValue)}var r=t.Styles[e.nodeName];if(r!=null){for(var l in r){this.styles[l]=r[l]}}if(this.attribute("class").hasValue()){var o=t.compressSpaces(this.attribute("class").value).split(" ");for(var h=0;h<o.length;h++){r=t.Styles["."+o[h]];if(r!=null){for(var l in r){this.styles[l]=r[l]}}r=t.Styles[e.nodeName+"."+o[h]];if(r!=null){for(var l in r){this.styles[l]=r[l]}}}}if(this.attribute("id").hasValue()){var r=t.Styles["#"+this.attribute("id").value];if(r!=null){for(var l in r){this.styles[l]=r[l]}}}if(this.attribute("style").hasValue()){var r=this.attribute("style").value.split(";");for(var i=0;i<r.length;i++){if(t.trim(r[i])!=""){var u=r[i].split(":");var l=t.trim(u[0]);var f=t.trim(u[1]);this.styles[l]=new t.Property(l,f)}}}if(this.attribute("id").hasValue()){if(t.Definitions[this.attribute("id").value]==null){t.Definitions[this.attribute("id").value]=this}}}};t.Element.RenderedElementBase=function(e){this.base=t.Element.ElementBase;this.base(e);this.setContext=function(e){if(this.style("fill").isUrlDefinition()){var i=this.style("fill").getFillStyleDefinition(this,this.style("fill-opacity"));if(i!=null)e.fillStyle=i}else if(this.style("fill").hasValue()){var n=this.style("fill");if(n.value=="currentColor")n.value=this.style("color").value;e.fillStyle=n.value=="none"?"rgba(0,0,0,0)":n.value}if(this.style("fill-opacity").hasValue()){var n=new t.Property("fill",e.fillStyle);n=n.addOpacity(this.style("fill-opacity").value);e.fillStyle=n.value}if(this.style("stroke").isUrlDefinition()){var i=this.style("stroke").getFillStyleDefinition(this,this.style("stroke-opacity"));if(i!=null)e.strokeStyle=i}else if(this.style("stroke").hasValue()){var a=this.style("stroke");if(a.value=="currentColor")a.value=this.style("color").value;e.strokeStyle=a.value=="none"?"rgba(0,0,0,0)":a.value}if(this.style("stroke-opacity").hasValue()){var a=new t.Property("stroke",e.strokeStyle);a=a.addOpacity(this.style("stroke-opacity").value);e.strokeStyle=a.value}if(this.style("stroke-width").hasValue()){var s=this.style("stroke-width").toPixels();e.lineWidth=s==0?.001:s}if(this.style("stroke-linecap").hasValue())e.lineCap=this.style("stroke-linecap").value;if(this.style("stroke-linejoin").hasValue())e.lineJoin=this.style("stroke-linejoin").value;if(this.style("stroke-miterlimit").hasValue())e.miterLimit=this.style("stroke-miterlimit").value;if(this.style("stroke-dasharray").hasValue()){var r=t.ToNumberArray(this.style("stroke-dasharray").value);if(typeof e.setLineDash!="undefined"){e.setLineDash(r)}else if(typeof e.webkitLineDash!="undefined"){e.webkitLineDash=r}else if(typeof e.mozDash!="undefined"){e.mozDash=r}var l=this.style("stroke-dashoffset").numValueOrDefault(1);if(typeof e.lineDashOffset!="undefined"){e.lineDashOffset=l}else if(typeof e.webkitLineDashOffset!="undefined"){e.webkitLineDashOffset=l}else if(typeof e.mozDashOffset!="undefined"){e.mozDashOffset=l}}if(typeof e.font!="undefined"){e.font=t.Font.CreateFont(this.style("font-style").value,this.style("font-variant").value,this.style("font-weight").value,this.style("font-size").hasValue()?this.style("font-size").toPixels()+"px":"",this.style("font-family").value).toString()}if(this.attribute("transform").hasValue()){var o=new t.Transform(this.attribute("transform").value);o.apply(e)}if(this.style("clip-path").hasValue()){var h=this.style("clip-path").getDefinition();if(h!=null)h.apply(e)}if(this.style("opacity").hasValue()){e.globalAlpha=this.style("opacity").numValue()}}};t.Element.RenderedElementBase.prototype=new t.Element.ElementBase;t.Element.PathElementBase=function(e){this.base=t.Element.RenderedElementBase;this.base(e);this.path=function(e){if(e!=null)e.beginPath();return new t.BoundingBox};this.renderChildren=function(e){this.path(e);t.Mouse.checkPath(this,e);if(e.fillStyle!=""){if(this.attribute("fill-rule").hasValue()){e.fill(this.attribute("fill-rule").value)}else{e.fill()}}if(e.strokeStyle!="")e.stroke();var i=this.getMarkers();if(i!=null){if(this.style("marker-start").isUrlDefinition()){var n=this.style("marker-start").getDefinition();n.render(e,i[0][0],i[0][1])}if(this.style("marker-mid").isUrlDefinition()){var n=this.style("marker-mid").getDefinition();for(var a=1;a<i.length-1;a++){n.render(e,i[a][0],i[a][1])}}if(this.style("marker-end").isUrlDefinition()){var n=this.style("marker-end").getDefinition();n.render(e,i[i.length-1][0],i[i.length-1][1])}}};this.getBoundingBox=function(){return this.path()};this.getMarkers=function(){return null}};t.Element.PathElementBase.prototype=new t.Element.RenderedElementBase;t.Element.svg=function(e){this.base=t.Element.RenderedElementBase;this.base(e);this.baseClearContext=this.clearContext;this.clearContext=function(e){this.baseClearContext(e);t.ViewPort.RemoveCurrent()};this.baseSetContext=this.setContext;this.setContext=function(e){e.strokeStyle="rgba(0,0,0,0)";e.lineCap="butt";e.lineJoin="miter";e.miterLimit=4;this.baseSetContext(e);if(!this.attribute("x").hasValue())this.attribute("x",true).value=0;if(!this.attribute("y").hasValue())this.attribute("y",true).value=0;e.translate(this.attribute("x").toPixels("x"),this.attribute("y").toPixels("y"));var i=t.ViewPort.width();var n=t.ViewPort.height();if(!this.attribute("width").hasValue())this.attribute("width",true).value="100%";if(!this.attribute("height").hasValue())this.attribute("height",true).value="100%";if(typeof this.root=="undefined"){i=this.attribute("width").toPixels("x");n=this.attribute("height").toPixels("y");var a=0;var s=0;if(this.attribute("refX").hasValue()&&this.attribute("refY").hasValue()){a=-this.attribute("refX").toPixels("x");s=-this.attribute("refY").toPixels("y")}e.beginPath();e.moveTo(a,s);e.lineTo(i,s);e.lineTo(i,n);e.lineTo(a,n);e.closePath();e.clip()}t.ViewPort.SetCurrent(i,n);if(this.attribute("viewBox").hasValue()){var r=t.ToNumberArray(this.attribute("viewBox").value);var l=r[0];var o=r[1];i=r[2];n=r[3];t.AspectRatio(e,this.attribute("preserveAspectRatio").value,t.ViewPort.width(),i,t.ViewPort.height(),n,l,o,this.attribute("refX").value,this.attribute("refY").value);t.ViewPort.RemoveCurrent();t.ViewPort.SetCurrent(r[2],r[3])}}};t.Element.svg.prototype=new t.Element.RenderedElementBase;t.Element.rect=function(e){this.base=t.Element.PathElementBase;this.base(e);this.path=function(e){var i=this.attribute("x").toPixels("x");var n=this.attribute("y").toPixels("y");var a=this.attribute("width").toPixels("x");var s=this.attribute("height").toPixels("y");var r=this.attribute("rx").toPixels("x");var l=this.attribute("ry").toPixels("y");if(this.attribute("rx").hasValue()&&!this.attribute("ry").hasValue())l=r;if(this.attribute("ry").hasValue()&&!this.attribute("rx").hasValue())r=l;r=Math.min(r,a/2);l=Math.min(l,s/2);if(e!=null){e.beginPath();e.moveTo(i+r,n);e.lineTo(i+a-r,n);e.quadraticCurveTo(i+a,n,i+a,n+l);e.lineTo(i+a,n+s-l);e.quadraticCurveTo(i+a,n+s,i+a-r,n+s);e.lineTo(i+r,n+s);e.quadraticCurveTo(i,n+s,i,n+s-l);e.lineTo(i,n+l);e.quadraticCurveTo(i,n,i+r,n);e.closePath()}return new t.BoundingBox(i,n,i+a,n+s)}};t.Element.rect.prototype=new t.Element.PathElementBase;t.Element.circle=function(e){this.base=t.Element.PathElementBase;this.base(e);this.path=function(e){var i=this.attribute("cx").toPixels("x");var n=this.attribute("cy").toPixels("y");var a=this.attribute("r").toPixels();if(e!=null){e.beginPath();e.arc(i,n,a,0,Math.PI*2,true);e.closePath()}return new t.BoundingBox(i-a,n-a,i+a,n+a)}};t.Element.circle.prototype=new t.Element.PathElementBase;t.Element.ellipse=function(e){this.base=t.Element.PathElementBase;this.base(e);this.path=function(e){var i=4*((Math.sqrt(2)-1)/3);var n=this.attribute("rx").toPixels("x");var a=this.attribute("ry").toPixels("y");var s=this.attribute("cx").toPixels("x");var r=this.attribute("cy").toPixels("y");if(e!=null){e.beginPath();e.moveTo(s,r-a);e.bezierCurveTo(s+i*n,r-a,s+n,r-i*a,s+n,r);e.bezierCurveTo(s+n,r+i*a,s+i*n,r+a,s,r+a);e.bezierCurveTo(s-i*n,r+a,s-n,r+i*a,s-n,r);e.bezierCurveTo(s-n,r-i*a,s-i*n,r-a,s,r-a);e.closePath()}return new t.BoundingBox(s-n,r-a,s+n,r+a)}};t.Element.ellipse.prototype=new t.Element.PathElementBase;t.Element.line=function(e){this.base=t.Element.PathElementBase;this.base(e);this.getPoints=function(){return[new t.Point(this.attribute("x1").toPixels("x"),this.attribute("y1").toPixels("y")),new t.Point(this.attribute("x2").toPixels("x"),this.attribute("y2").toPixels("y"))]};this.path=function(e){var i=this.getPoints();if(e!=null){e.beginPath();e.moveTo(i[0].x,i[0].y);e.lineTo(i[1].x,i[1].y)}return new t.BoundingBox(i[0].x,i[0].y,i[1].x,i[1].y)};this.getMarkers=function(){var t=this.getPoints();var e=t[0].angleTo(t[1]);return[[t[0],e],[t[1],e]]}};t.Element.line.prototype=new t.Element.PathElementBase;t.Element.polyline=function(e){this.base=t.Element.PathElementBase;this.base(e);this.points=t.CreatePath(this.attribute("points").value);this.path=function(e){var i=new t.BoundingBox(this.points[0].x,this.points[0].y);if(e!=null){e.beginPath();e.moveTo(this.points[0].x,this.points[0].y)}for(var n=1;n<this.points.length;n++){i.addPoint(this.points[n].x,this.points[n].y);if(e!=null)e.lineTo(this.points[n].x,this.points[n].y)}return i};this.getMarkers=function(){var t=[];for(var e=0;e<this.points.length-1;e++){t.push([this.points[e],this.points[e].angleTo(this.points[e+1])])}t.push([this.points[this.points.length-1],t[t.length-1][1]]);return t}};t.Element.polyline.prototype=new t.Element.PathElementBase;t.Element.polygon=function(e){this.base=t.Element.polyline;this.base(e);this.basePath=this.path;this.path=function(t){var e=this.basePath(t);if(t!=null){t.lineTo(this.points[0].x,this.points[0].y);t.closePath()}return e}};t.Element.polygon.prototype=new t.Element.polyline;t.Element.path=function(e){this.base=t.Element.PathElementBase;this.base(e);var i=this.attribute("d").value;i=i.replace(/,/gm," ");i=i.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");i=i.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");i=i.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,"$1 $2");i=i.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");i=i.replace(/([0-9])([+\-])/gm,"$1 $2");i=i.replace(/(\.[0-9]*)(\.)/gm,"$1 $2");i=i.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,"$1 $3 $4 ");i=t.compressSpaces(i);i=t.trim(i);this.PathParser=new function(e){this.tokens=e.split(" ");this.reset=function(){this.i=-1;this.command="";this.previousCommand="";this.start=new t.Point(0,0);this.control=new t.Point(0,0);this.current=new t.Point(0,0);this.points=[];this.angles=[]};this.isEnd=function(){return this.i>=this.tokens.length-1};this.isCommandOrEnd=function(){if(this.isEnd())return true;return this.tokens[this.i+1].match(/^[A-Za-z]$/)!=null};this.isRelativeCommand=function(){switch(this.command){case"m":case"l":case"h":case"v":case"c":case"s":case"q":case"t":case"a":case"z":return true;break}return false};this.getToken=function(){this.i++;return this.tokens[this.i]};this.getScalar=function(){return parseFloat(this.getToken())};this.nextCommand=function(){this.previousCommand=this.command;this.command=this.getToken()};this.getPoint=function(){var e=new t.Point(this.getScalar(),this.getScalar());return this.makeAbsolute(e)};this.getAsControlPoint=function(){var t=this.getPoint();this.control=t;return t};this.getAsCurrentPoint=function(){var t=this.getPoint();this.current=t;return t};this.getReflectedControlPoint=function(){if(this.previousCommand.toLowerCase()!="c"&&this.previousCommand.toLowerCase()!="s"&&this.previousCommand.toLowerCase()!="q"&&this.previousCommand.toLowerCase()!="t"){return this.current}var e=new t.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y);return e};this.makeAbsolute=function(t){if(this.isRelativeCommand()){t.x+=this.current.x;t.y+=this.current.y}return t};this.addMarker=function(t,e,i){if(i!=null&&this.angles.length>0&&this.angles[this.angles.length-1]==null){this.angles[this.angles.length-1]=this.points[this.points.length-1].angleTo(i)}this.addMarkerAngle(t,e==null?null:e.angleTo(t))};this.addMarkerAngle=function(t,e){this.points.push(t);this.angles.push(e)};this.getMarkerPoints=function(){return this.points};this.getMarkerAngles=function(){for(var t=0;t<this.angles.length;t++){if(this.angles[t]==null){for(var e=t+1;e<this.angles.length;e++){if(this.angles[e]!=null){this.angles[t]=this.angles[e];break}}}}return this.angles}}(i);this.path=function(e){var i=this.PathParser;i.reset();var n=new t.BoundingBox;if(e!=null)e.beginPath();while(!i.isEnd()){i.nextCommand();switch(i.command){case"M":case"m":var a=i.getAsCurrentPoint();i.addMarker(a);n.addPoint(a.x,a.y);if(e!=null)e.moveTo(a.x,a.y);i.start=i.current;while(!i.isCommandOrEnd()){var a=i.getAsCurrentPoint();i.addMarker(a,i.start);n.addPoint(a.x,a.y);if(e!=null)e.lineTo(a.x,a.y)}break;case"L":case"l":while(!i.isCommandOrEnd()){var s=i.current;var a=i.getAsCurrentPoint();i.addMarker(a,s);n.addPoint(a.x,a.y);if(e!=null)e.lineTo(a.x,a.y)}break;case"H":case"h":while(!i.isCommandOrEnd()){var r=new t.Point((i.isRelativeCommand()?i.current.x:0)+i.getScalar(),i.current.y);i.addMarker(r,i.current);i.current=r;n.addPoint(i.current.x,i.current.y);if(e!=null)e.lineTo(i.current.x,i.current.y)}break;case"V":case"v":while(!i.isCommandOrEnd()){var r=new t.Point(i.current.x,(i.isRelativeCommand()?i.current.y:0)+i.getScalar());i.addMarker(r,i.current);i.current=r;n.addPoint(i.current.x,i.current.y);if(e!=null)e.lineTo(i.current.x,i.current.y)}break;case"C":case"c":while(!i.isCommandOrEnd()){var l=i.current;var o=i.getPoint();var h=i.getAsControlPoint();var u=i.getAsCurrentPoint();i.addMarker(u,h,o);n.addBezierCurve(l.x,l.y,o.x,o.y,h.x,h.y,u.x,u.y);if(e!=null)e.bezierCurveTo(o.x,o.y,h.x,h.y,u.x,u.y)}break;case"S":case"s":while(!i.isCommandOrEnd()){var l=i.current;var o=i.getReflectedControlPoint();var h=i.getAsControlPoint();var u=i.getAsCurrentPoint();i.addMarker(u,h,o);n.addBezierCurve(l.x,l.y,o.x,o.y,h.x,h.y,u.x,u.y);if(e!=null)e.bezierCurveTo(o.x,o.y,h.x,h.y,u.x,u.y)}break;case"Q":case"q":while(!i.isCommandOrEnd()){var l=i.current;var h=i.getAsControlPoint();var u=i.getAsCurrentPoint();i.addMarker(u,h,h);n.addQuadraticCurve(l.x,l.y,h.x,h.y,u.x,u.y);if(e!=null)e.quadraticCurveTo(h.x,h.y,u.x,u.y)}break;case"T":case"t":while(!i.isCommandOrEnd()){var l=i.current;var h=i.getReflectedControlPoint();i.control=h;var u=i.getAsCurrentPoint();i.addMarker(u,h,h);n.addQuadraticCurve(l.x,l.y,h.x,h.y,u.x,u.y);if(e!=null)e.quadraticCurveTo(h.x,h.y,u.x,u.y)}break;case"A":case"a":while(!i.isCommandOrEnd()){var l=i.current;var f=i.getScalar();var c=i.getScalar();var m=i.getScalar()*(Math.PI/180);var v=i.getScalar();var d=i.getScalar();var u=i.getAsCurrentPoint();var p=new t.Point(Math.cos(m)*(l.x-u.x)/2+Math.sin(m)*(l.y-u.y)/2,-Math.sin(m)*(l.x-u.x)/2+Math.cos(m)*(l.y-u.y)/2);var y=Math.pow(p.x,2)/Math.pow(f,2)+Math.pow(p.y,2)/Math.pow(c,2);if(y>1){f*=Math.sqrt(y);c*=Math.sqrt(y)}var g=(v==d?-1:1)*Math.sqrt((Math.pow(f,2)*Math.pow(c,2)-Math.pow(f,2)*Math.pow(p.y,2)-Math.pow(c,2)*Math.pow(p.x,2))/(Math.pow(f,2)*Math.pow(p.y,2)+Math.pow(c,2)*Math.pow(p.x,2)));if(isNaN(g))g=0;var x=new t.Point(g*f*p.y/c,g*-c*p.x/f);var b=new t.Point((l.x+u.x)/2+Math.cos(m)*x.x-Math.sin(m)*x.y,(l.y+u.y)/2+Math.sin(m)*x.x+Math.cos(m)*x.y);var E=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))};var P=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(E(t)*E(e))};var w=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(P(t,e))};var B=w([1,0],[(p.x-x.x)/f,(p.y-x.y)/c]);var C=[(p.x-x.x)/f,(p.y-x.y)/c];var V=[(-p.x-x.x)/f,(-p.y-x.y)/c];var T=w(C,V);if(P(C,V)<=-1)T=Math.PI;if(P(C,V)>=1)T=0;var M=1-d?1:-1;var k=B+M*(T/2);var S=new t.Point(b.x+f*Math.cos(k),b.y+c*Math.sin(k));i.addMarkerAngle(S,k-M*Math.PI/2);i.addMarkerAngle(u,k-M*Math.PI);n.addPoint(u.x,u.y);if(e!=null){var P=f>c?f:c;var A=f>c?1:f/c;var D=f>c?c/f:1;e.translate(b.x,b.y);e.rotate(m);e.scale(A,D);e.arc(0,0,P,B,B+T,1-d);e.scale(1/A,1/D);e.rotate(-m);e.translate(-b.x,-b.y)}}break;case"Z":case"z":if(e!=null)e.closePath();i.current=i.start}}return n};this.getMarkers=function(){var t=this.PathParser.getMarkerPoints();var e=this.PathParser.getMarkerAngles();var i=[];for(var n=0;n<t.length;n++){i.push([t[n],e[n]])}return i}};t.Element.path.prototype=new t.Element.PathElementBase;t.Element.pattern=function(e){this.base=t.Element.ElementBase;this.base(e);this.createPattern=function(e,i){var n=this.attribute("width").toPixels("x",true);var a=this.attribute("height").toPixels("y",true);var s=new t.Element.svg;s.attributes["viewBox"]=new t.Property("viewBox",this.attribute("viewBox").value);s.attributes["width"]=new t.Property("width",n+"px");s.attributes["height"]=new t.Property("height",a+"px");s.attributes["transform"]=new t.Property("transform",this.attribute("patternTransform").value);s.children=this.children;var r=document.createElement("canvas");r.width=n;r.height=a;var l=r.getContext("2d");if(this.attribute("x").hasValue()&&this.attribute("y").hasValue()){l.translate(this.attribute("x").toPixels("x",true),this.attribute("y").toPixels("y",true))}for(var o=-1;o<=1;o++){for(var h=-1;h<=1;h++){l.save();l.translate(o*r.width,h*r.height);s.render(l);l.restore()}}var u=e.createPattern(r,"repeat");return u}};t.Element.pattern.prototype=new t.Element.ElementBase;t.Element.marker=function(e){this.base=t.Element.ElementBase;this.base(e);this.baseRender=this.render;this.render=function(e,i,n){e.translate(i.x,i.y);if(this.attribute("orient").valueOrDefault("auto")=="auto")e.rotate(n);if(this.attribute("markerUnits").valueOrDefault("strokeWidth")=="strokeWidth")e.scale(e.lineWidth,e.lineWidth);e.save();var a=new t.Element.svg;a.attributes["viewBox"]=new t.Property("viewBox",this.attribute("viewBox").value);a.attributes["refX"]=new t.Property("refX",this.attribute("refX").value);a.attributes["refY"]=new t.Property("refY",this.attribute("refY").value);a.attributes["width"]=new t.Property("width",this.attribute("markerWidth").value);a.attributes["height"]=new t.Property("height",this.attribute("markerHeight").value);a.attributes["fill"]=new t.Property("fill",this.attribute("fill").valueOrDefault("black"));a.attributes["stroke"]=new t.Property("stroke",this.attribute("stroke").valueOrDefault("none"));a.children=this.children;a.render(e);e.restore();if(this.attribute("markerUnits").valueOrDefault("strokeWidth")=="strokeWidth")e.scale(1/e.lineWidth,1/e.lineWidth);

if(this.attribute("orient").valueOrDefault("auto")=="auto")e.rotate(-n);e.translate(-i.x,-i.y)}};t.Element.marker.prototype=new t.Element.ElementBase;t.Element.defs=function(e){this.base=t.Element.ElementBase;this.base(e);this.render=function(t){}};t.Element.defs.prototype=new t.Element.ElementBase;t.Element.GradientBase=function(e){this.base=t.Element.ElementBase;this.base(e);this.gradientUnits=this.attribute("gradientUnits").valueOrDefault("objectBoundingBox");this.stops=[];for(var i=0;i<this.children.length;i++){var n=this.children[i];if(n.type=="stop")this.stops.push(n)}this.getGradient=function(){};this.createGradient=function(e,i,n){var a=this;if(this.getHrefAttribute().hasValue()){a=this.getHrefAttribute().getDefinition()}var s=function(e){if(n.hasValue()){var i=new t.Property("color",e);return i.addOpacity(n.value).value}return e};var r=this.getGradient(e,i);if(r==null)return s(a.stops[a.stops.length-1].color);for(var l=0;l<a.stops.length;l++){r.addColorStop(a.stops[l].offset,s(a.stops[l].color))}if(this.attribute("gradientTransform").hasValue()){var o=t.ViewPort.viewPorts[0];var h=new t.Element.rect;h.attributes["x"]=new t.Property("x",-t.MAX_VIRTUAL_PIXELS/3);h.attributes["y"]=new t.Property("y",-t.MAX_VIRTUAL_PIXELS/3);h.attributes["width"]=new t.Property("width",t.MAX_VIRTUAL_PIXELS);h.attributes["height"]=new t.Property("height",t.MAX_VIRTUAL_PIXELS);var u=new t.Element.g;u.attributes["transform"]=new t.Property("transform",this.attribute("gradientTransform").value);u.children=[h];var f=new t.Element.svg;f.attributes["x"]=new t.Property("x",0);f.attributes["y"]=new t.Property("y",0);f.attributes["width"]=new t.Property("width",o.width);f.attributes["height"]=new t.Property("height",o.height);f.children=[u];var c=document.createElement("canvas");c.width=o.width;c.height=o.height;var m=c.getContext("2d");m.fillStyle=r;f.render(m);return m.createPattern(c,"no-repeat")}return r}};t.Element.GradientBase.prototype=new t.Element.ElementBase;t.Element.linearGradient=function(e){this.base=t.Element.GradientBase;this.base(e);this.getGradient=function(t,e){var i=e.getBoundingBox();if(!this.attribute("x1").hasValue()&&!this.attribute("y1").hasValue()&&!this.attribute("x2").hasValue()&&!this.attribute("y2").hasValue()){this.attribute("x1",true).value=0;this.attribute("y1",true).value=0;this.attribute("x2",true).value=1;this.attribute("y2",true).value=0}var n=this.gradientUnits=="objectBoundingBox"?i.x()+i.width()*this.attribute("x1").numValue():this.attribute("x1").toPixels("x");var a=this.gradientUnits=="objectBoundingBox"?i.y()+i.height()*this.attribute("y1").numValue():this.attribute("y1").toPixels("y");var s=this.gradientUnits=="objectBoundingBox"?i.x()+i.width()*this.attribute("x2").numValue():this.attribute("x2").toPixels("x");var r=this.gradientUnits=="objectBoundingBox"?i.y()+i.height()*this.attribute("y2").numValue():this.attribute("y2").toPixels("y");if(n==s&&a==r)return null;return t.createLinearGradient(n,a,s,r)}};t.Element.linearGradient.prototype=new t.Element.GradientBase;t.Element.radialGradient=function(e){this.base=t.Element.GradientBase;this.base(e);this.getGradient=function(t,e){var i=e.getBoundingBox();if(!this.attribute("cx").hasValue())this.attribute("cx",true).value="50%";if(!this.attribute("cy").hasValue())this.attribute("cy",true).value="50%";if(!this.attribute("r").hasValue())this.attribute("r",true).value="50%";var n=this.gradientUnits=="objectBoundingBox"?i.x()+i.width()*this.attribute("cx").numValue():this.attribute("cx").toPixels("x");var a=this.gradientUnits=="objectBoundingBox"?i.y()+i.height()*this.attribute("cy").numValue():this.attribute("cy").toPixels("y");var s=n;var r=a;if(this.attribute("fx").hasValue()){s=this.gradientUnits=="objectBoundingBox"?i.x()+i.width()*this.attribute("fx").numValue():this.attribute("fx").toPixels("x")}if(this.attribute("fy").hasValue()){r=this.gradientUnits=="objectBoundingBox"?i.y()+i.height()*this.attribute("fy").numValue():this.attribute("fy").toPixels("y")}var l=this.gradientUnits=="objectBoundingBox"?(i.width()+i.height())/2*this.attribute("r").numValue():this.attribute("r").toPixels();return t.createRadialGradient(s,r,0,n,a,l)}};t.Element.radialGradient.prototype=new t.Element.GradientBase;t.Element.stop=function(e){this.base=t.Element.ElementBase;this.base(e);this.offset=this.attribute("offset").numValue();if(this.offset<0)this.offset=0;if(this.offset>1)this.offset=1;var i=this.style("stop-color");if(this.style("stop-opacity").hasValue())i=i.addOpacity(this.style("stop-opacity").value);this.color=i.value};t.Element.stop.prototype=new t.Element.ElementBase;t.Element.AnimateBase=function(e){this.base=t.Element.ElementBase;this.base(e);t.Animations.push(this);this.duration=0;this.begin=this.attribute("begin").toMilliseconds();this.maxDuration=this.begin+this.attribute("dur").toMilliseconds();this.getProperty=function(){var t=this.attribute("attributeType").value;var e=this.attribute("attributeName").value;if(t=="CSS"){return this.parent.style(e,true)}return this.parent.attribute(e,true)};this.initialValue=null;this.initialUnits="";this.removed=false;this.calcValue=function(){return""};this.update=function(t){if(this.initialValue==null){this.initialValue=this.getProperty().value;this.initialUnits=this.getProperty().getUnits()}if(this.duration>this.maxDuration){if(this.attribute("repeatCount").value=="indefinite"||this.attribute("repeatDur").value=="indefinite"){this.duration=0}else if(this.attribute("fill").valueOrDefault("remove")=="remove"&&!this.removed){this.removed=true;this.getProperty().value=this.initialValue;return true}else{return false}}this.duration=this.duration+t;var e=false;if(this.begin<this.duration){var i=this.calcValue();if(this.attribute("type").hasValue()){var n=this.attribute("type").value;i=n+"("+i+")"}this.getProperty().value=i;e=true}return e};this.from=this.attribute("from");this.to=this.attribute("to");this.values=this.attribute("values");if(this.values.hasValue())this.values.value=this.values.value.split(";");this.progress=function(){var e={progress:(this.duration-this.begin)/(this.maxDuration-this.begin)};if(this.values.hasValue()){var i=e.progress*(this.values.value.length-1);var n=Math.floor(i),a=Math.ceil(i);e.from=new t.Property("from",parseFloat(this.values.value[n]));e.to=new t.Property("to",parseFloat(this.values.value[a]));e.progress=(i-n)/(a-n)}else{e.from=this.from;e.to=this.to}return e}};t.Element.AnimateBase.prototype=new t.Element.ElementBase;t.Element.animate=function(e){this.base=t.Element.AnimateBase;this.base(e);this.calcValue=function(){var t=this.progress();var e=t.from.numValue()+(t.to.numValue()-t.from.numValue())*t.progress;return e+this.initialUnits}};t.Element.animate.prototype=new t.Element.AnimateBase;t.Element.animateColor=function(e){this.base=t.Element.AnimateBase;this.base(e);this.calcValue=function(){var t=this.progress();var e=new RGBColor(t.from.value);var i=new RGBColor(t.to.value);if(e.ok&&i.ok){var n=e.r+(i.r-e.r)*t.progress;var a=e.g+(i.g-e.g)*t.progress;var s=e.b+(i.b-e.b)*t.progress;return"rgb("+parseInt(n,10)+","+parseInt(a,10)+","+parseInt(s,10)+")"}return this.attribute("from").value}};t.Element.animateColor.prototype=new t.Element.AnimateBase;t.Element.animateTransform=function(e){this.base=t.Element.AnimateBase;this.base(e);this.calcValue=function(){var e=this.progress();var i=t.ToNumberArray(e.from.value);var n=t.ToNumberArray(e.to.value);var a="";for(var s=0;s<i.length;s++){a+=i[s]+(n[s]-i[s])*e.progress+" "}return a}};t.Element.animateTransform.prototype=new t.Element.animate;t.Element.font=function(e){this.base=t.Element.ElementBase;this.base(e);this.horizAdvX=this.attribute("horiz-adv-x").numValue();this.isRTL=false;this.isArabic=false;this.fontFace=null;this.missingGlyph=null;this.glyphs=[];for(var i=0;i<this.children.length;i++){var n=this.children[i];if(n.type=="font-face"){this.fontFace=n;if(n.style("font-family").hasValue()){t.Definitions[n.style("font-family").value]=this}}else if(n.type=="missing-glyph")this.missingGlyph=n;else if(n.type=="glyph"){if(n.arabicForm!=""){this.isRTL=true;this.isArabic=true;if(typeof this.glyphs[n.unicode]=="undefined")this.glyphs[n.unicode]=[];this.glyphs[n.unicode][n.arabicForm]=n}else{this.glyphs[n.unicode]=n}}}};t.Element.font.prototype=new t.Element.ElementBase;t.Element.fontface=function(e){this.base=t.Element.ElementBase;this.base(e);this.ascent=this.attribute("ascent").value;this.descent=this.attribute("descent").value;this.unitsPerEm=this.attribute("units-per-em").numValue()};t.Element.fontface.prototype=new t.Element.ElementBase;t.Element.missingglyph=function(e){this.base=t.Element.path;this.base(e);this.horizAdvX=0};t.Element.missingglyph.prototype=new t.Element.path;t.Element.glyph=function(e){this.base=t.Element.path;this.base(e);this.horizAdvX=this.attribute("horiz-adv-x").numValue();this.unicode=this.attribute("unicode").value;this.arabicForm=this.attribute("arabic-form").value};t.Element.glyph.prototype=new t.Element.path;t.Element.text=function(e){this.captureTextNodes=true;this.base=t.Element.RenderedElementBase;this.base(e);this.baseSetContext=this.setContext;this.setContext=function(t){this.baseSetContext(t);if(this.style("dominant-baseline").hasValue())t.textBaseline=this.style("dominant-baseline").value;if(this.style("alignment-baseline").hasValue())t.textBaseline=this.style("alignment-baseline").value};this.getBoundingBox=function(){return new t.BoundingBox(this.attribute("x").toPixels("x"),this.attribute("y").toPixels("y"),0,0)};this.renderChildren=function(t){this.x=this.attribute("x").toPixels("x");this.y=this.attribute("y").toPixels("y");this.x+=this.getAnchorDelta(t,this,0);for(var e=0;e<this.children.length;e++){this.renderChild(t,this,e)}};this.getAnchorDelta=function(t,e,i){var n=this.style("text-anchor").valueOrDefault("start");if(n!="start"){var a=0;for(var s=i;s<e.children.length;s++){var r=e.children[s];if(s>i&&r.attribute("x").hasValue())break;a+=r.measureTextRecursive(t)}return-1*(n=="end"?a:a/2)}return 0};this.renderChild=function(t,e,i){var n=e.children[i];if(n.attribute("x").hasValue()){n.x=n.attribute("x").toPixels("x")+this.getAnchorDelta(t,e,i)}else{if(this.attribute("dx").hasValue())this.x+=this.attribute("dx").toPixels("x");if(n.attribute("dx").hasValue())this.x+=n.attribute("dx").toPixels("x");n.x=this.x}this.x=n.x+n.measureText(t);if(n.attribute("y").hasValue()){n.y=n.attribute("y").toPixels("y")}else{if(this.attribute("dy").hasValue())this.y+=this.attribute("dy").toPixels("y");if(n.attribute("dy").hasValue())this.y+=n.attribute("dy").toPixels("y");n.y=this.y}this.y=n.y;n.render(t);for(var i=0;i<n.children.length;i++){this.renderChild(t,n,i)}}};t.Element.text.prototype=new t.Element.RenderedElementBase;t.Element.TextElementBase=function(e){this.base=t.Element.RenderedElementBase;this.base(e);this.getGlyph=function(t,e,i){var n=e[i];var a=null;if(t.isArabic){var s="isolated";if((i==0||e[i-1]==" ")&&i<e.length-2&&e[i+1]!=" ")s="terminal";if(i>0&&e[i-1]!=" "&&i<e.length-2&&e[i+1]!=" ")s="medial";if(i>0&&e[i-1]!=" "&&(i==e.length-1||e[i+1]==" "))s="initial";if(typeof t.glyphs[n]!="undefined"){a=t.glyphs[n][s];if(a==null&&t.glyphs[n].type=="glyph")a=t.glyphs[n]}}else{a=t.glyphs[n]}if(a==null)a=t.missingGlyph;return a};this.renderChildren=function(e){var i=this.parent.style("font-family").getDefinition();if(i!=null){var n=this.parent.style("font-size").numValueOrDefault(t.Font.Parse(t.ctx.font).fontSize);var a=this.parent.style("font-style").valueOrDefault(t.Font.Parse(t.ctx.font).fontStyle);var s=this.getText();if(i.isRTL)s=s.split("").reverse().join("");var r=t.ToNumberArray(this.parent.attribute("dx").value);for(var l=0;l<s.length;l++){var o=this.getGlyph(i,s,l);var h=n/i.fontFace.unitsPerEm;e.translate(this.x,this.y);e.scale(h,-h);var u=e.lineWidth;e.lineWidth=e.lineWidth*i.fontFace.unitsPerEm/n;if(a=="italic")e.transform(1,0,.4,1,0,0);o.render(e);if(a=="italic")e.transform(1,0,-.4,1,0,0);e.lineWidth=u;e.scale(1/h,-1/h);e.translate(-this.x,-this.y);this.x+=n*(o.horizAdvX||i.horizAdvX)/i.fontFace.unitsPerEm;if(typeof r[l]!="undefined"&&!isNaN(r[l])){this.x+=r[l]}}return}if(e.fillStyle!="")e.fillText(t.compressSpaces(this.getText()),this.x,this.y);if(e.strokeStyle!="")e.strokeText(t.compressSpaces(this.getText()),this.x,this.y)};this.getText=function(){};this.measureTextRecursive=function(t){var e=this.measureText(t);for(var i=0;i<this.children.length;i++){e+=this.children[i].measureTextRecursive(t)}return e};this.measureText=function(e){var i=this.parent.style("font-family").getDefinition();if(i!=null){var n=this.parent.style("font-size").numValueOrDefault(t.Font.Parse(t.ctx.font).fontSize);var a=0;var s=this.getText();if(i.isRTL)s=s.split("").reverse().join("");var r=t.ToNumberArray(this.parent.attribute("dx").value);for(var l=0;l<s.length;l++){var o=this.getGlyph(i,s,l);a+=(o.horizAdvX||i.horizAdvX)*n/i.fontFace.unitsPerEm;if(typeof r[l]!="undefined"&&!isNaN(r[l])){a+=r[l]}}return a}var h=t.compressSpaces(this.getText());if(!e.measureText)return h.length*10;e.save();this.setContext(e);var u=e.measureText(h).width;e.restore();return u}};t.Element.TextElementBase.prototype=new t.Element.RenderedElementBase;t.Element.tspan=function(e){this.captureTextNodes=true;this.base=t.Element.TextElementBase;this.base(e);this.text=e.nodeValue||e.text||"";this.getText=function(){return this.text}};t.Element.tspan.prototype=new t.Element.TextElementBase;t.Element.tref=function(e){this.base=t.Element.TextElementBase;this.base(e);this.getText=function(){var t=this.getHrefAttribute().getDefinition();if(t!=null)return t.children[0].getText()}};t.Element.tref.prototype=new t.Element.TextElementBase;t.Element.a=function(e){this.base=t.Element.TextElementBase;this.base(e);this.hasText=true;for(var i=0;i<e.childNodes.length;i++){if(e.childNodes[i].nodeType!=3)this.hasText=false}this.text=this.hasText?e.childNodes[0].nodeValue:"";this.getText=function(){return this.text};this.baseRenderChildren=this.renderChildren;this.renderChildren=function(e){if(this.hasText){this.baseRenderChildren(e);var i=new t.Property("fontSize",t.Font.Parse(t.ctx.font).fontSize);t.Mouse.checkBoundingBox(this,new t.BoundingBox(this.x,this.y-i.toPixels("y"),this.x+this.measureText(e),this.y))}else{var n=new t.Element.g;n.children=this.children;n.parent=this;n.render(e)}};this.onclick=function(){window.open(this.getHrefAttribute().value)};this.onmousemove=function(){t.ctx.canvas.style.cursor="pointer"}};t.Element.a.prototype=new t.Element.TextElementBase;t.Element.image=function(e){this.base=t.Element.RenderedElementBase;this.base(e);var i=this.getHrefAttribute().value;var n=i.match(/\.svg$/);t.Images.push(this);this.loaded=false;if(!n){this.img=document.createElement("img");var a=this;this.img.onload=function(){a.loaded=true};this.img.onerror=function(){if(typeof console!="undefined"){console.log('ERROR: image "'+i+'" not found');a.loaded=true}};this.img.src=i}else{this.img=t.ajax(i);this.loaded=true}this.renderChildren=function(e){var i=this.attribute("x").toPixels("x");var a=this.attribute("y").toPixels("y");var s=this.attribute("width").toPixels("x");var r=this.attribute("height").toPixels("y");if(s==0||r==0)return;e.save();if(n){e.drawSvg(this.img,i,a,s,r)}else{e.translate(i,a);t.AspectRatio(e,this.attribute("preserveAspectRatio").value,s,this.img.width,r,this.img.height,0,0);e.drawImage(this.img,0,0)}e.restore()};this.getBoundingBox=function(){var e=this.attribute("x").toPixels("x");var i=this.attribute("y").toPixels("y");var n=this.attribute("width").toPixels("x");var a=this.attribute("height").toPixels("y");return new t.BoundingBox(e,i,e+n,i+a)}};t.Element.image.prototype=new t.Element.RenderedElementBase;t.Element.g=function(e){this.base=t.Element.RenderedElementBase;this.base(e);this.getBoundingBox=function(){var e=new t.BoundingBox;for(var i=0;i<this.children.length;i++){e.addBoundingBox(this.children[i].getBoundingBox())}return e}};t.Element.g.prototype=new t.Element.RenderedElementBase;t.Element.symbol=function(e){this.base=t.Element.RenderedElementBase;this.base(e);this.baseSetContext=this.setContext;this.setContext=function(e){this.baseSetContext(e);if(this.attribute("viewBox").hasValue()){var i=t.ToNumberArray(this.attribute("viewBox").value);var n=i[0];var a=i[1];width=i[2];height=i[3];t.AspectRatio(e,this.attribute("preserveAspectRatio").value,this.attribute("width").toPixels("x"),width,this.attribute("height").toPixels("y"),height,n,a);t.ViewPort.SetCurrent(i[2],i[3])}}};t.Element.symbol.prototype=new t.Element.RenderedElementBase;t.Element.style=function(e){this.base=t.Element.ElementBase;this.base(e);var i="";for(var n=0;n<e.childNodes.length;n++){i+=e.childNodes[n].nodeValue}i=i.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"");i=t.compressSpaces(i);var a=i.split("}");for(var n=0;n<a.length;n++){if(t.trim(a[n])!=""){var s=a[n].split("{");var r=s[0].split(",");var l=s[1].split(";");for(var o=0;o<r.length;o++){var h=t.trim(r[o]);if(h!=""){var u={};for(var f=0;f<l.length;f++){var c=l[f].indexOf(":");var m=l[f].substr(0,c);var v=l[f].substr(c+1,l[f].length-c);if(m!=null&&v!=null){u[t.trim(m)]=new t.Property(t.trim(m),t.trim(v))}}t.Styles[h]=u;if(h=="@font-face"){var d=u["font-family"].value.replace(/"/g,"");var p=u["src"].value.split(",");for(var y=0;y<p.length;y++){if(p[y].indexOf('format("svg")')>0){var g=p[y].indexOf("url");var x=p[y].indexOf(")",g);var b=p[y].substr(g+5,x-g-6);var E=t.parseXml(t.ajax(b));var P=E.getElementsByTagName("font");for(var w=0;w<P.length;w++){var B=t.CreateElement(P[w]);t.Definitions[d]=B}}}}}}}}};t.Element.style.prototype=new t.Element.ElementBase;t.Element.use=function(e){this.base=t.Element.RenderedElementBase;this.base(e);this.baseSetContext=this.setContext;this.setContext=function(t){this.baseSetContext(t);if(this.attribute("x").hasValue())t.translate(this.attribute("x").toPixels("x"),0);if(this.attribute("y").hasValue())t.translate(0,this.attribute("y").toPixels("y"))};this.getDefinition=function(){var t=this.getHrefAttribute().getDefinition();if(this.attribute("width").hasValue())t.attribute("width",true).value=this.attribute("width").value;if(this.attribute("height").hasValue())t.attribute("height",true).value=this.attribute("height").value;return t};this.path=function(t){var e=this.getDefinition();if(e!=null)e.path(t)};this.getBoundingBox=function(){var t=this.getDefinition();if(t!=null)return t.getBoundingBox()};this.renderChildren=function(t){var e=this.getDefinition();if(e!=null){var i=e.parent;e.parent=null;e.render(t);e.parent=i}}};t.Element.use.prototype=new t.Element.RenderedElementBase;t.Element.mask=function(e){this.base=t.Element.ElementBase;this.base(e);this.apply=function(e,i){var n=this.attribute("x").toPixels("x");var a=this.attribute("y").toPixels("y");var s=this.attribute("width").toPixels("x");var r=this.attribute("height").toPixels("y");if(s==0&&r==0){var l=new t.BoundingBox;for(var o=0;o<this.children.length;o++){l.addBoundingBox(this.children[o].getBoundingBox())}var n=Math.floor(l.x1);var a=Math.floor(l.y1);var s=Math.floor(l.width());var r=Math.floor(l.height())}var h=i.attribute("mask").value;i.attribute("mask").value="";var u=document.createElement("canvas");u.width=n+s;u.height=a+r;var f=u.getContext("2d");this.renderChildren(f);var c=document.createElement("canvas");c.width=n+s;c.height=a+r;var m=c.getContext("2d");i.render(m);m.globalCompositeOperation="destination-in";m.fillStyle=f.createPattern(u,"no-repeat");m.fillRect(0,0,n+s,a+r);e.fillStyle=m.createPattern(c,"no-repeat");e.fillRect(0,0,n+s,a+r);i.attribute("mask").value=h};this.render=function(t){}};t.Element.mask.prototype=new t.Element.ElementBase;t.Element.clipPath=function(e){this.base=t.Element.ElementBase;this.base(e);this.apply=function(e){for(var i=0;i<this.children.length;i++){var n=this.children[i];if(typeof n.path!="undefined"){var a=null;if(n.attribute("transform").hasValue()){a=new t.Transform(n.attribute("transform").value);a.apply(e)}n.path(e);e.clip();if(a){a.unapply(e)}}}};this.render=function(t){}};t.Element.clipPath.prototype=new t.Element.ElementBase;t.Element.filter=function(e){this.base=t.Element.ElementBase;this.base(e);this.apply=function(t,e){var i=e.getBoundingBox();var n=Math.floor(i.x1);var a=Math.floor(i.y1);var s=Math.floor(i.width());var r=Math.floor(i.height());var l=e.style("filter").value;e.style("filter").value="";var o=0,h=0;for(var u=0;u<this.children.length;u++){var f=this.children[u].extraFilterDistance||0;o=Math.max(o,f);h=Math.max(h,f)}var c=document.createElement("canvas");c.width=s+2*o;c.height=r+2*h;var m=c.getContext("2d");m.translate(-n+o,-a+h);e.render(m);for(var u=0;u<this.children.length;u++){this.children[u].apply(m,0,0,s+2*o,r+2*h)}t.drawImage(c,0,0,s+2*o,r+2*h,n-o,a-h,s+2*o,r+2*h);e.style("filter",true).value=l};this.render=function(t){}};t.Element.filter.prototype=new t.Element.ElementBase;t.Element.feMorphology=function(e){this.base=t.Element.ElementBase;this.base(e);this.apply=function(t,e,i,n,a){}};t.Element.feMorphology.prototype=new t.Element.ElementBase;t.Element.feColorMatrix=function(e){this.base=t.Element.ElementBase;this.base(e);function i(t,e,i,n,a,s){return t[i*n*4+e*4+s]}function n(t,e,i,n,a,s,r){t[i*n*4+e*4+s]=r}this.apply=function(t,e,a,s,r){var l=t.getImageData(0,0,s,r);for(var a=0;a<r;a++){for(var e=0;e<s;e++){var o=i(l.data,e,a,s,r,0);var h=i(l.data,e,a,s,r,1);var u=i(l.data,e,a,s,r,2);var f=(o+h+u)/3;n(l.data,e,a,s,r,0,f);n(l.data,e,a,s,r,1,f);n(l.data,e,a,s,r,2,f)}}t.clearRect(0,0,s,r);t.putImageData(l,0,0)}};t.Element.feColorMatrix.prototype=new t.Element.ElementBase;t.Element.feGaussianBlur=function(e){this.base=t.Element.ElementBase;this.base(e);this.blurRadius=Math.floor(this.attribute("stdDeviation").numValue());this.extraFilterDistance=this.blurRadius;this.apply=function(e,i,n,a,s){if(typeof stackBlurCanvasRGBA=="undefined"){if(typeof console!="undefined"){console.log("ERROR: StackBlur.js must be included for blur to work")}return}e.canvas.id=t.UniqueId();e.canvas.style.display="none";document.body.appendChild(e.canvas);stackBlurCanvasRGBA(e.canvas.id,i,n,a,s,this.blurRadius);document.body.removeChild(e.canvas)}};t.Element.feGaussianBlur.prototype=new t.Element.ElementBase;t.Element.title=function(t){};t.Element.title.prototype=new t.Element.ElementBase;t.Element.desc=function(t){};t.Element.desc.prototype=new t.Element.ElementBase;t.Element.MISSING=function(t){if(typeof console!="undefined"){console.log("ERROR: Element '"+t.nodeName+"' not yet implemented.")}};t.Element.MISSING.prototype=new t.Element.ElementBase;t.CreateElement=function(e){var i=e.nodeName.replace(/^[^:]+:/,"");i=i.replace(/\-/g,"");var n=null;if(typeof t.Element[i]!="undefined"){n=new t.Element[i](e)}else{n=new t.Element.MISSING(e)}n.type=e.nodeName;return n};t.load=function(e,i){t.loadXml(e,t.ajax(i))};t.loadXml=function(e,i){t.loadXmlDoc(e,t.parseXml(i))};t.loadXmlDoc=function(e,i){t.init(e);var n=function(t){var i=e.canvas;while(i){t.x-=i.offsetLeft;t.y-=i.offsetTop;i=i.offsetParent}if(window.scrollX)t.x+=window.scrollX;if(window.scrollY)t.y+=window.scrollY;return t};if(t.opts["ignoreMouse"]!=true){e.canvas.onclick=function(e){var i=n(new t.Point(e!=null?e.clientX:event.clientX,e!=null?e.clientY:event.clientY));t.Mouse.onclick(i.x,i.y)};e.canvas.onmousemove=function(e){var i=n(new t.Point(e!=null?e.clientX:event.clientX,e!=null?e.clientY:event.clientY));t.Mouse.onmousemove(i.x,i.y)}}var a=t.CreateElement(i.documentElement);a.root=true;var s=true;var r=function(){t.ViewPort.Clear();if(e.canvas.parentNode)t.ViewPort.SetCurrent(e.canvas.parentNode.clientWidth,e.canvas.parentNode.clientHeight);if(t.opts["ignoreDimensions"]!=true){if(a.style("width").hasValue()){e.canvas.width=a.style("width").toPixels("x");e.canvas.style.width=e.canvas.width+"px"}if(a.style("height").hasValue()){e.canvas.height=a.style("height").toPixels("y");e.canvas.style.height=e.canvas.height+"px"}}var n=e.canvas.clientWidth||e.canvas.width;var r=e.canvas.clientHeight||e.canvas.height;if(t.opts["ignoreDimensions"]==true&&a.style("width").hasValue()&&a.style("height").hasValue()){n=a.style("width").toPixels("x");r=a.style("height").toPixels("y")}t.ViewPort.SetCurrent(n,r);if(t.opts["offsetX"]!=null)a.attribute("x",true).value=t.opts["offsetX"];if(t.opts["offsetY"]!=null)a.attribute("y",true).value=t.opts["offsetY"];if(t.opts["scaleWidth"]!=null&&t.opts["scaleHeight"]!=null){var l=1,o=1,h=t.ToNumberArray(a.attribute("viewBox").value);if(a.attribute("width").hasValue())l=a.attribute("width").toPixels("x")/t.opts["scaleWidth"];else if(!isNaN(h[2]))l=h[2]/t.opts["scaleWidth"];if(a.attribute("height").hasValue())o=a.attribute("height").toPixels("y")/t.opts["scaleHeight"];else if(!isNaN(h[3]))o=h[3]/t.opts["scaleHeight"];a.attribute("width",true).value=t.opts["scaleWidth"];a.attribute("height",true).value=t.opts["scaleHeight"];a.attribute("viewBox",true).value="0 0 "+n*l+" "+r*o;a.attribute("preserveAspectRatio",true).value="none"}if(t.opts["ignoreClear"]!=true){e.clearRect(0,0,n,r)}a.render(e);if(s){s=false;if(typeof t.opts["renderCallback"]=="function")t.opts["renderCallback"](i)}};var l=true;if(t.ImagesLoaded()){l=false;r()}t.intervalID=setInterval(function(){var e=false;if(l&&t.ImagesLoaded()){l=false;e=true}if(t.opts["ignoreMouse"]!=true){e=e|t.Mouse.hasEvents()}if(t.opts["ignoreAnimation"]!=true){for(var i=0;i<t.Animations.length;i++){e=e|t.Animations[i].update(1e3/t.FRAMERATE)}}if(typeof t.opts["forceRedraw"]=="function"){if(t.opts["forceRedraw"]()==true)e=true}if(e){r();t.Mouse.runEvents()}},1e3/t.FRAMERATE)};t.stop=function(){if(t.intervalID){clearInterval(t.intervalID)}};t.Mouse=new function(){this.events=[];this.hasEvents=function(){return this.events.length!=0};this.onclick=function(t,e){this.events.push({type:"onclick",x:t,y:e,run:function(t){if(t.onclick)t.onclick()}})};this.onmousemove=function(t,e){this.events.push({type:"onmousemove",x:t,y:e,run:function(t){if(t.onmousemove)t.onmousemove()}})};this.eventElements=[];this.checkPath=function(t,e){for(var i=0;i<this.events.length;i++){var n=this.events[i];if(e.isPointInPath&&e.isPointInPath(n.x,n.y))this.eventElements[i]=t}};this.checkBoundingBox=function(t,e){for(var i=0;i<this.events.length;i++){var n=this.events[i];if(e.isPointInBox(n.x,n.y))this.eventElements[i]=t}};this.runEvents=function(){t.ctx.canvas.style.cursor="";for(var e=0;e<this.events.length;e++){var i=this.events[e];var n=this.eventElements[e];while(n){i.run(n);n=n.parent}}this.events=[];this.eventElements=[]}};return t}})();if(typeof CanvasRenderingContext2D!="undefined"){CanvasRenderingContext2D.prototype.drawSvg=function(t,e,i,n,a){canvg(this.canvas,t,{ignoreMouse:true,ignoreAnimation:true,ignoreDimensions:true,ignoreClear:true,offsetX:e,offsetY:i,scaleWidth:n,scaleHeight:a})}}
//# sourceMappingURL=canvg.map.js